
	$(function(){
				var list=$("#propertyIds").val();
				var arr=list.split(",");
				for(var i=0;i<arr.length;i++)
				{
					var id="#"+arr[i];
					$(id).removeAttr("disabled");
					if(arr[i]=='fwzh'){
						var inputs=$("#fwzh").find("input");
						for(var j=0;j<inputs.length;j++){
							inputs[j].disabled=false;
						}
						$("#postFont2").attr("disabled","");
					}
					if($(id).is("textarea")){
					$(id).attr("tableIndex","yes");
					$(id).attr("style"," width:500px; height:100px; border:1; overflow:hidden");
					$(id).parent().append("<input type=\"button\" class=\"button_02\" onclick=\"OpenComment('"+arr[i]+"')\" value=\"办公语\">");
					}
				}
				if($("#zwbj").attr("disabled")){
				$("#zwbj").removeAttr("disabled");
				$("#zwbj").removeAttr("onclick");
				$("#zwbj").bind('click',function(){
					draftWord(0);
				});
			}
			}
		);
		
function enableFields(fields) {
	for (var i = 0; i < fields.length; i++) {
		var field = fields[i];
		if (field instanceof (Array)) {
			for (var j = 0; j < field.length; j++) {
				field[j].disabled = false;
			}
		} else {
			field.disabled = false;
		}
	}
}

function getUserDate(name){
		var d = new Date();
		var vYear = d.getFullYear();
		var vMon = d.getMonth() + 1;
		var vDay = d.getDate();
		var h = d.getHours(); 
		var m = d.getMinutes(); 
		var se = d.getSeconds(); 
		var s=vYear+"-"+(vMon<10 ? "0" + vMon : vMon)+"-"+(vDay<10 ? "0"+ vDay : vDay)+" "+ (h<10 ? "0"+ h : h)+":"+ (m<10 ? "0" + m : m)+":"+ (se<10 ? "0" +se : se);
		var nbsp = "";
		for(var i = 0; i <= 18; i++){
			nbsp += "  ";
		}
		return nbsp+name+"  ("+s+")";
}

function validate() {
	var list = $("#mustPropertyIds").val();
	var arr = list.split(",");
	for (var i = 0; i < arr.length; i++) {
		var id = "#" + arr[i];
		var value = $(id).val();
		if ($.trim(value) == "" || $.trim(value) == "null") {
			alert("\u5fc5\u586b\u9009\u9879\u4e0d\u80fd\u4e3a\u7a7a");
			return;
		}
	}
}
function download() {
	var fileId = $("#fileArray").val();
	if (fileId != "" && fileId != "null") {
		var param = {"fileArray":fileId};
		$.post("getFileList.action", param, function (data) {
			var list = data.fileList;
			for (var i = 0; i < list.length; i++) {
				$("#filetable").prepend("<tr><td><input type=\"checkbox\" name=\"checkbox2\" id=\"" + list[i].id + "\" value=\"" + list[i].id + "\" />&nbsp;<a href=\"downLoadFile.action?fileId=" + list[i].id + "\">" + list[i].name + "</a>&nbsp;</tr>");
			}
		}, "json");
	}
}
function setValue(value, val) {
	var arr = eval(value);
	var names = "";
	var ids = "";
	for (i = 0; i < arr.length; i++) {
		ids = ids + "," + arr[i].value;
		names = names + "," + arr[i].name;
	}
	if (names.length > 0) {
		names = names.substring(1);
		ids = ids.substring(1);
	}
	document.getElementById("names" + val).value = names;
	document.getElementById("users" + val).value = ids;
}
function getOldValue(val) {
	var ids = document.getElementById("users" + val).value;
	var names = document.getElementById("names" + val).value;
	var array = "";
	if (ids != "" && ids != "null") {
		var idarray = ids.split(",");
		var namearray = names.split(",");
		for (var i = 0; i < idarray.length; i++) {
			if (i == 0) {
				array += "{\"value\":" + idarray[i] + ",\"name\":\"" + namearray[i] + "\"}";
			} else {
				array += ",{\"value\":" + idarray[i] + ",\"name\":\"" + namearray[i] + "\"}";
			}
		}
	}
	return array;
}
function savedraft(action,val) {
	var url = action;
	var table=$("#filetable").find("input[type=\"checkbox\"]");
	var fileId="";
	for(var i=0;i<table.length;i++){
		fileId+="_"+table[i].value;
	}
	$("#fileArray").val(fileId);
	if(val=='receive'){
	var textIds=$("#zhengwentable").find("input[type=\"checkbox\"]");
	var idArr="";
	for(var i=0;i<textIds.length;i++){
			idArr+="_"+textIds[i].value;
		}
		$("#textId").val(idArr);
	}
	$.post(url, $("form").serialize(), function (data) {
		if (data == "success") {
			alert("\u64cd\u4f5c\u6210\u529f");
			if(val=='receive'){
			window.close();
			window.opener.location.reload();
			}else{
			window.close();
			window.opener.location.reload();
			}
		} else {
			alert("\u64cd\u4f5c\u5931\u8d25");
		}
	});
}
function reject(val,statu) {
	var nodeId=$("#backNodeId").val();
	var status="";
	var message=document.getElementsByName("message");
	for(var i=0;i<message.length;i++){
		if(message[i].checked){
			status="1";
		}
	}
	var param={"docId":val,"status":nodeId,"message":status};
	$.post("rejectDocment.action", param, function (data) {
		if (data == "success") {
			alert("\u64cd\u4f5c\u6210\u529f");
			window.close();
			if($("#status").val()=='index'){
				window.opener.flowList();
			}else{
				var currentPage=$("#currentPage").val();
				window.opener.page(currentPage);
			}
		} else {
			alert("\u64cd\u4f5c\u5931\u8d25");
		}
	});
}

function getcandidateR(id) {
	var flag=validateReceive();
		if(!flag){
			return;
		}
	var url = "getCandidate.action?nodeId=" + id;
	openWindow(url, 700, 400);
}
function getorguserR(id) {
	var flag=validateReceive();
		if(!flag){
			return;
		}
	var url = "getOrgExecutor.action?nodeId=" + id;
	openWindow(url, 700, 420);
}


function selectUserR(val){
		var flag=validateReceive();
		if(!flag){
			return;
		}
		var url="getFlowOrgUser.action?status="+val;
		openWindow(url,700,420);
	}

function selectUserS(val){
		var flag=validateSend();
		if(!flag){
			return;
		}
		var url="getFlowOrgUser.action?status="+val;
		openWindow(url,700,400);
	}


function getcandidateS(id) {
	var flag=validateSend();
		if(!flag){
			return;
		}
	var url = "getCandidate.action?nodeId=" + id;
	openWindow(url, 700, 400);
}
function getorguserS(id) {
	var flag=validateSend();
		if(!flag){
			return;
		}
	var url = "getOrgExecutor.action?nodeId=" + id;
	openWindow(url, 700, 400);
}

function draftWord(val) {
	var id=$("#contentid").val();
	var docId=$("#docId").val();
	var template=$("#template").val();
	var wt=$("#wt").val();
	var postFont1=$("#postFont1").val();
	var postFont2=$("#postFont2").val();
	var postFont3=$("#postFont3").val();
	var fwbt=$("#fwbt").val();
	var ztc=$("#ztc").val();
	var zs=$("#zs").val();
	var cs=$("#cs").val();
	var yfrq=$("#yfrq").val();
	var gy=$("#gy").val();
	var url = "wordChange.action?contentId="+id+"&editType="+val+"&docId="+docId+"&document.template="+template+"&document.top="+wt+"&document.postFont1="+postFont1+"&document.postFont2="+postFont2+"&document.postFont3="+postFont3+"&document.title="+fwbt+"&document.them="+ztc+"&document.writeFrom="+cs+"&document.printTime="+yfrq+"&document.print="+gy+"&document.sendFrom="+zs;
	openWindow(encodeURI(encodeURI(url)),screen.width,screen.height);
}


function flowLook(val) {
	var url = "flowLook.action?flowId="+val;
	openWindow(url, 680, 600);
}

function validateReceive(){
		var print=$("#fs").val();
		var title=$("#bt").val();
		var postFont3=$("#postFont3").val();
		if(title==""||title==null){
			alert("标题不能为空");
			return false;
		}
		var reg=/^[1-9]\d*$/;		
		if(print!=""&&print!=null){
			if(!reg.test(print)){alert("打印份数只能为数字");
			return false;}
		}
		if(postFont3!='null'&&postFont3!=''){
			if(!reg.test(postFont3)){
			alert("编号只能为数字");
			return false;
			}
		}
		return true;
}

function validateSend(){
		var print=$("#gy").val();
		var title=$("#fwbt").val();
		var postFont3=$("#postFont3").val();
		if(title==""||title=='null'){
			alert("发文标题不能为空");
			return false;
		}
		var reg=/^[1-9]\d*$/;
		if(print!=''&&print!='null'){
		if(!reg.test(print)){
			alert("打印份数只能为数字");
			return false;
			}
		}
		if(postFont3!='null'&&postFont3!=''){
			if(!reg.test(postFont3)){
			alert("发文字号只能为数字");
			return false;
			}
		}
		return true;
}

function getFiles(val,fileId) {
	var fileId = $("#"+fileId).val();
	if (fileId != "" && fileId != "null") {
		var param = {"fileArray":fileId};
		$.post("getFileList.action", param, function (data) {
			var list = data.fileList;
			for (var i = 0; i < list.length; i++) {
				$("#"+val).prepend("<tr><td><input type=\"checkbox\" name=\"checkbox2\" id=\"" + list[i].id + "\" value=\"" + list[i].id + "\" />&nbsp;<a href=\"downLoadFile.action?fileId=" + list[i].id + "\">" + list[i].name + "</a>&nbsp;</tr>");
			}
		}, "json");
	}
}

function backShow(val){
	if(val=='notShow'){
		document.getElementById("notShow").style.display = "none";
		document.getElementById("backList").style.display = "block";
	}else if(val=='backList'){
		document.getElementById("notShow").style.display = "block";
		document.getElementById("backList").style.display = "none";
	}else if(val=='notShow2'){
		document.getElementById("notShow2").style.display = "none";
		document.getElementById("backList2").style.display = "block";
	}else if(val=='backList2'){
		document.getElementById("notShow2").style.display = "block";
		document.getElementById("backList2").style.display = "none";
	}
}


function topChange(val){
	if(val!=''){
	var font2=$("#postFont2").val();
	var param={"name":val,"department":font2,"status":"1"};
	$.post("getDispatcherTopShort.action",param,function(data){
		var shortName=data.shortName;
		var maxTop=data.maxTop;
		$("#postFont1").val(shortName);
		$("#postFont3").val(maxTop);
	},"json");
	}
}
function topChangeDate(val){
	if(val!=''){
	var wt=$("#wt").val();
	var param={"name":wt,"department":val,"status":"1"};
	$.post("getDispatcherTopShort.action",param,function(data){
		var maxTop=data.maxTop;
		$("#postFont3").val(maxTop);
	},"json");
	}
}

function typeChange(val){
	if(val!=''){
	var font2=$("#postFont2").val();
	$("#postFont1").val(val);
	var param={"name":val,"department":font2,"status":"2"};
	$.post("getReceiveType.action",param,function(data){
		var maxTop=data.maxTop;
		$("#postFont3").val(maxTop);
	},"json");
	}
}


function typeChangeDate(val){
	if(val!=''){
	var lx=$("#lx").val();
	var param={"name":lx,"department":val,"status":"2"};
	$.post("getReceiveType.action",param,function(data){
		var maxTop=data.maxTop;
		$("#postFont3").val(maxTop);
	},"json");
	}
}


	function OpenComment(msg){
		var massage=$("#"+msg).val();
		var a=massage.indexOf(" ");
		var sign=massage.substring(0,a);
		var URL = "getWorkLanAll.action?location="+msg+"&message="+sign;
		openWindow(encodeURI(encodeURI(URL)),400,300);
	}
	
	function SetVerifyComment(location,message){
		$("#"+location).val(message);
	}